package cn.com.server.common;

import java.io.Serializable;

import com.github.pagehelper.Page;

/**
 * 异步请求返回对象,根据layui2.2.2
 * @author admin
 *
 */
public class AjaxObject implements Serializable{
	
	private static final long serialVersionUID = 1L;
	/**
	 * 请求状态
	 */
	private int code = 0;
	/**
	 * 提示信息
	 */
	private String msg = "";
	
	/**
	 * 数据总长度
	 */
	private long count = 0;
	
	/**
	 * 请求数据
	 */
	private Object data = "";
	
	/**
	 *空构造函数
	 */
	public AjaxObject() {
		
	}
	
	/**
	 * 设置状态及提示信息
	 * @param status
	 * @param msg
	 */
	public AjaxObject(int code,String msg) {
		this.code = code;
		this.msg = msg;
	}
	
	/**
	 * 设置状态及提示信息和数据
	 * @param status
	 * @param msg
	 */
	public AjaxObject(int code,String msg,Object data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	
	/**
	 * 设置状态及提示信息和分页数据
	 * @param status
	 * @param msg
	 */
	public AjaxObject(int code,String msg,Page<?> page) {
		this.code = code;
		this.msg = msg;
		this.count = page.getTotal();
		this.data = page.getResult();
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public long getCount() {
		return count;
	}

	public void setCount(long count) {
		this.count = count;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
	public void setData(Page<?> page) {
		this.count = page.getTotal();
		this.data = page.getResult();
	}
}
